package com.neuedu.controller;


import com.neuedu.pojo.Income;
import com.neuedu.service.IIncomeService;
import com.neuedu.util.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wk
 * @since 2020-09-14
 */
@RestController
@RequestMapping("/income")
public class IncomeController {
    @Resource
    IIncomeService incomeService;
    @PostMapping("list")
    CommonResult list(Income income){
        System.out.println("打印输入");
        System.out.println(income);
        //return CommonResult.failed();
        return incomeService.list(income);
    }

    @PostMapping("del")
    CommonResult del(Integer id){
        return incomeService.del(id);
    }
    @GetMapping("getById")
    CommonResult getById(Integer id){
        return CommonResult.success(incomeService.getById(id));
    }
    @PostMapping("update")
    CommonResult update(Income income){
        return CommonResult.success(incomeService.updateById(income));
    }
    @PostMapping("add")
    CommonResult add(Income income){
        return CommonResult.success(incomeService.save(income));
    }
    @PostMapping("back")
    CommonResult back(Integer id){
        Income income = new Income();
        income.setId(id);
        income.setActive(1);
        return CommonResult.success(incomeService.updateById(income));
    }
}
